<template>
  <div class="search-item search-input-container">
    <el-input
      v-model="internalValue"
      size="small"
      :placeholder="placeholder"
      clearable
    />
  </div>
</template>
<script>
export default {
  name: 'SearchInput',
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    placeholder: {
      type: String,
      default: ''
    }
  },
  computed: {
    internalValue: {
      get() {
        return this.value
      },
      set(val) {
        this.$emit('input', val)
      }
    }
  },
  created() {
    this.$on('search-clear', function() {
      this.internalValue = ''
    })
  }
}
</script>
